package lab03.test05;

import java.io.*;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by 星月 on 2017/12/03.
 */
public class Test {
    public static void main(String[] args) {
        File file=new File("D:\\java实验\\Hello.txt");
        FileWriter fileWriter=null;
        FileReader fileReader=null;
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入需要进行转化的字符串：");
        String string=sc.next();
        //将string字符串转化为单个字符数组
        char[] c=string.toCharArray();
        //算法转换
        char[] a =new char[c.length];
        for (int i=0;i<c.length;i++){
            a[i]=(char)((int)c[i]+1);
        }
        System.out.println(a);

        try {
            fileWriter=new FileWriter(file);
            fileReader=new FileReader(file);
            fileWriter.write(Arrays.toString(a));

            int data=0;
            while ((data=fileReader.read())!=-1){
                System.out.println((char)data);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
